﻿using System;
using System.Windows.Forms;
using static MatrixEditor.Utilities;

namespace MatrixEditor
{
	public partial class FrmAbout : Form
	{
		public FrmAbout() => InitializeComponent();

		private void FrmAbout_Load(object sender, EventArgs e)
		{
			Version version;
			var assemblies = AppDomain.CurrentDomain.GetAssemblies();

			foreach (var assembly in assemblies)
			{
                if (assembly.GetName().Name == "Matrix Editor")
				{
					version = assembly.GetName().Version;
					LabelProductName1.Text = assembly.GetName().Name;
					LabelVersion1.Text = $"Version: {version.Major}.{version.Minor}.{version.Build}";
				}
				else if (assembly.GetName().Name == "Matrix Controls")
				{
					version = assembly.GetName().Version;
					LabelProductName2.Text = assembly.GetName().Name;
					LabelVersion2.Text = $"Version: {version.Major}.{version.Minor}.{version.Build}";
				}
			}

			Text = $"关于 - {Application.ProductName}";
		}

		private void LinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			OpenUrlOrFile(LinkLabel1.Text.Split('|')[1]);
		}

		private void LinkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			OpenUrlOrFile(LinkLabel2.Text.Split('|')[1]);
		}

		private void ButtonOK_Click(object sender, EventArgs e) => Close();
	}
}
